#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 410;
const int B = 205;

int n, x[N], L, f[N][N][N][2], t[N], ans;

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	n = in, L = in;
	rep(i, 1, n) x[i + B] = in, x[B - n + i - 1] = x[i + B] - L;
	rep(i, 1, n) t[i + B] = t[B - n + i - 1] = in;
	memset(f, 0x3f, sizeof f);
	f[B][B][0][0] = f[B][B][0][1] = 0;
	rep(len, 0, n)
		rep(l, B - len, B) {
		int r = l + len;
		rep(k, 0, len) if(f[l][r][k][0] <= 1e9 || f[l][r][k][1] <= 1e9) {
			chkmax(ans, k); 
			chkmin(f[l][r][k][1], f[l][r][k][0] + x[r] - x[l]);
			chkmin(f[l][r][k][0], f[l][r][k][1] + x[r] - x[l]);
			if(l > B - n) chkmin(f[l - 1][r][k + (f[l][r][k][0] + x[l] - x[l - 1] <= t[l - 1])][0], f[l][r][k][0] + x[l] - x[l - 1]);
			if(r < B + n) chkmin(f[l][r + 1][k + (f[l][r][k][1] + x[r + 1] - x[r] <= t[r + 1])][1], f[l][r][k][1] + x[r + 1] - x[r]);
		}
	} printf("%d\n", ans);
	return 0;
}
